package it.ap.sa.core.configuration.policy;

import com.fasterxml.jackson.annotation.JsonFormat;

import it.ap.sa.core.utils.LocaleUtilCtrl;

/**
 * @author Alessandro Paolillo
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum RPolicyManagerType {
    CH_PASSWORD(
    		"ch_password", 
    		LocaleUtilCtrl.getMessage("GestPolicy.tipo.ch_password.label", LocaleUtilCtrl.getLocale()), 
    		LocaleUtilCtrl.getMessage("GestPolicy.tipo.ch_password.description", LocaleUtilCtrl.getLocale()), 
    		"it.eng.tz.core.policy.service.ChPasswordRPolicyManager"),
    RECONNECT("reconnect", 
    		LocaleUtilCtrl.getMessage("GestPolicy.tipo.reconnect.label", LocaleUtilCtrl.getLocale()), 
    		LocaleUtilCtrl.getMessage("GestPolicy.tipo.ch_password.description", LocaleUtilCtrl.getLocale()), 
    		"it.eng.tz.core.policy.service.LogoutRPolicyManager");
	
	
	/** Codice che individua la policy(es: ch_password, reconnect, ecc..) */
    private String code;
    /** nome breve **/
    private String label;
    /** descrizione estesa **/
    private String description;
	/** classe che implementa la logica della policy */
	private String classe;
    
    /**
     */
    private RPolicyManagerType(String code, String label, String description, String classe) {
        this.code = code;
        this.label = label;
        this.description = description;
        this.classe = classe;
    }
    
    /**
     * Ritorna la policy type dato il codice.
     * @param code
     * @return
     */
    public static RPolicyManagerType fromCode(String code) {
		for (RPolicyManagerType item : values()) {
			if (item.code.equals(code)) return item;
		}
		throw new IllegalArgumentException();
	}
 
    public String getCode() { return code; }
    public String getLabel() { return label; }
    public String getDescription() { return description; }
	public String getClasse() { return classe; }
	

	@Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("Type");
        sb.append("{");
        sb.append(" code=").append(code);
        sb.append(",label='").append(label).append('\'');
        sb.append(",description='").append(description).append('\'');
        sb.append(",classe='").append(classe).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
